package com.zoro.jianyue.ui.activity;

import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.animation.Animation;
import android.widget.ImageView;
import android.widget.TextView;

import com.zoro.jianyue.presenter.impl.SplashPresenterImpl;
import com.zoro.jianyue.presenter.Presenter;
import com.zoro.jianyue.R;
import com.zoro.jianyue.ui.base.BaseActivity;
import com.zoro.jianyue.view.SplashView;

import butterknife.Bind;

public class SplashActivity extends BaseActivity implements SplashView {
    @Bind(R.id.splash_image)
     ImageView mSplashImage;
    @Bind(R.id.splash_version_name)
     TextView mVersionName;
    @Bind(R.id.splash_copyright)
     TextView mCopyRight;

    private Presenter mSplashPresenter = null;

    @Override
    protected void initViewsAndEvents() {
        mSplashPresenter = new SplashPresenterImpl(this, this);
        mSplashPresenter.initialized();
    }

    @Override
    protected int setContentViewLayoutId() {
        return R.layout.activity_splash;
    }

    @Override
    protected void getBudleExtras(Bundle extras) {
    }

    @Override
    protected View getLoadingTargetView() {
        return null;
    }

    @Override
    protected boolean isApplyKitKatTransLucency() {
        return false;
    }

    @Override
    public void animateBackgroundImage(Animation animation) {
        mSplashImage.startAnimation(animation);
    }

    @Override
    public void initializeViews(String versionName, String copyRight, int background) {
        mCopyRight.setText(copyRight);
        mVersionName.setText(versionName);
        mSplashImage.setImageResource(background);
    }

    @Override
    public void navigateToHomePage() {
        readyGoThenKill(HomeActivity.class);
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }
}
